home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / New System Software Extensions / QuickDraw™ 3D 1.0 / Development / Interfaces / QD3DSet.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-02  |  9.9 KB  |  309 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DSet.h                                                 **
  4.  **                                                                             **
  5.  **                                                                             **
  6.  **     Purpose:     Set types and routines                                     **
  7.  **                                                                             **
  8.  **                                                                             **
  9.  **                                                                             **
  10.  **     Copyright (C) 1992-1995 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                             **
  12.  **                                                                             **
  13.  *****************************************************************************/
  14. #ifndef QD3DSet_h
  15. #define QD3DSet_h
  16.  
  17. #ifndef QD3D_h
  18. #include "QD3D.h"
  19. #endif  /*  QD3D_h  */
  20.  
  21. #if PRAGMA_ONCE
  22.     #pragma once
  23. #endif
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif    /* __cplusplus */
  28.  
  29.  
  30. /******************************************************************************
  31.  **                                                                             **
  32.  **                                Set Types                                     **
  33.  **                                                                             **
  34.  *****************************************************************************/
  35.  
  36. typedef long                    TQ3ElementType;
  37.  
  38. #define kQ3ElementTypeNone        0
  39. #define kQ3ElementTypeUnknown    32
  40.  
  41. /* 
  42.  *    kQ3ElementTypeUnknown is an TQ3Object. 
  43.  *    
  44.  *        Do Q3Set_Add(s, ..., &obj) or Q3Set_Get(s, ..., &obj);
  45.  *        
  46.  *        Note that the object is always referenced when copying around. 
  47.  *        
  48.  *        Generally, it is an Unknown object, a Group of Unknown objects, or a 
  49.  *        group of other "objects" which have been found in the metafile and
  50.  *        have no attachment method to their parent. Be prepared to handle
  51.  *        any or all of these cases if you actually access the set on a shape.
  52.  */
  53.  
  54. /******************************************************************************
  55.  **                                                                             **
  56.  **                                Set Routines                                 **
  57.  **                                                                             **
  58.  *****************************************************************************/
  59.  
  60. QD3D_EXPORT TQ3SetObject Q3Set_New(
  61.     void);
  62.  
  63. QD3D_EXPORT TQ3ObjectType Q3Set_GetType(
  64.     TQ3SetObject        set);
  65.  
  66. QD3D_EXPORT TQ3Status Q3Set_Add(
  67.     TQ3SetObject         set, 
  68.     TQ3ElementType        type,
  69.     const void             *data);
  70.  
  71. QD3D_EXPORT TQ3Status Q3Set_Get(
  72.     TQ3SetObject         set,
  73.     TQ3ElementType        type,
  74.     void                *data);
  75.  
  76. QD3D_EXPORT TQ3Boolean Q3Set_Contains(
  77.     TQ3SetObject         set,
  78.     TQ3ElementType        type);
  79.  
  80. QD3D_EXPORT TQ3Status Q3Set_Clear(
  81.     TQ3SetObject         set, 
  82.     TQ3ElementType        type);
  83.  
  84. QD3D_EXPORT TQ3Status Q3Set_Empty(
  85.     TQ3SetObject         target);
  86.  
  87. /*
  88.  *  Iterating through all elements in a set
  89.  *
  90.  *  Pass in kQ3ElementTypeNone to get first type
  91.  *  kQ3ElementTypeNone is returned when end of list is reached
  92.  */
  93. QD3D_EXPORT TQ3Status Q3Set_GetNextElementType(
  94.     TQ3SetObject         set,
  95.     TQ3ElementType        *type);        
  96.  
  97.  
  98. /******************************************************************************
  99.  **                                                                             **
  100.  **                                Attribute Types                                 **
  101.  **                                                                             **
  102.  *****************************************************************************/
  103.  
  104. /* 
  105.  *    For the data types listed below, pass in a pointer to it in the _Add 
  106.  *    and _Get calls.
  107.  *
  108.  *    For surface shader attributes, reference counts are incremented on 
  109.  *    the _Add and _Get 
  110.  */
  111.  
  112. typedef enum TQ3AttributeTypes {                /* Data Type                */
  113.     kQ3AttributeTypeNone                =  0,    /* ---------                */
  114.     kQ3AttributeTypeSurfaceUV            =  1,    /* TQ3Param2D                */ 
  115.     kQ3AttributeTypeShadingUV            =  2,    /* TQ3Param2D                 */
  116.     kQ3AttributeTypeNormal                =  3,    /* TQ3Vector3D                 */
  117.     kQ3AttributeTypeAmbientCoefficient    =  4,    /* float                     */
  118.     kQ3AttributeTypeDiffuseColor        =  5,    /* TQ3ColorRGB                */
  119.     kQ3AttributeTypeSpecularColor        =  6,    /* TQ3ColorRGB                */
  120.     kQ3AttributeTypeSpecularControl        =  7,    /* float                    */
  121.     kQ3AttributeTypeTransparencyColor    =  8,    /* TQ3ColorRGB                */
  122.     kQ3AttributeTypeSurfaceTangent        =  9,    /* TQ3Tangent2D              */
  123.     kQ3AttributeTypeHighlightState        = 10,    /* TQ3Switch                 */
  124.     kQ3AttributeTypeSurfaceShader        = 11,    /* TQ3SurfaceShaderObject    */
  125.     kQ3AttributeTypeNumTypes
  126. } TQ3AttributeTypes;
  127.  
  128. typedef TQ3ElementType TQ3AttributeType;
  129.  
  130.  
  131. /******************************************************************************
  132.  **                                                                             **
  133.  **                                Attribute Drawing                             **
  134.  **                                                                             **
  135.  *****************************************************************************/
  136.  
  137. QD3D_EXPORT TQ3Status Q3Attribute_Submit(
  138.     TQ3AttributeType        attributeType,
  139.     const void                *data,
  140.     TQ3ViewObject            view);
  141.  
  142.  
  143. /******************************************************************************
  144.  **                                                                             **
  145.  **                            AttributeSet Routines                             **
  146.  **                                                                             **
  147.  *****************************************************************************/
  148.  
  149. QD3D_EXPORT TQ3AttributeSet Q3AttributeSet_New(
  150.     void);
  151.  
  152. QD3D_EXPORT TQ3Status Q3AttributeSet_Add(
  153.     TQ3AttributeSet         attributeSet, 
  154.     TQ3AttributeType        type,
  155.     const void                 *data);
  156.  
  157. QD3D_EXPORT TQ3Boolean Q3AttributeSet_Contains(
  158.     TQ3AttributeSet            attributeSet,
  159.     TQ3AttributeType        attributeType);
  160.  
  161. QD3D_EXPORT TQ3Status Q3AttributeSet_Get(
  162.     TQ3AttributeSet         attributeSet,
  163.     TQ3AttributeType        type,
  164.     void                    *data);
  165.  
  166. QD3D_EXPORT TQ3Status Q3AttributeSet_Clear(
  167.     TQ3AttributeSet         attributeSet,
  168.     TQ3AttributeType        type);
  169.  
  170. QD3D_EXPORT TQ3Status Q3AttributeSet_Empty(
  171.     TQ3AttributeSet         target);
  172.  
  173. /*
  174.  * Q3AttributeSet_GetNextAttributeType
  175.  *
  176.  * Pass in kQ3AttributeTypeNone to get first type
  177.  * kQ3AttributeTypeNone is returned when end of list is reached
  178.  */
  179. QD3D_EXPORT TQ3Status Q3AttributeSet_GetNextAttributeType(
  180.     TQ3AttributeSet         source,
  181.     TQ3AttributeType        *type);        
  182.  
  183. QD3D_EXPORT TQ3Status Q3AttributeSet_Submit(
  184.     TQ3AttributeSet            attributeSet, 
  185.     TQ3ViewObject            view);
  186.  
  187. /*
  188.  * Inherit from parent->child into result
  189.  *    Result attributes are:
  190.  *        all child attributes + all parent attributes NOT in the child
  191.  */
  192. QD3D_EXPORT TQ3Status Q3AttributeSet_Inherit(
  193.     TQ3AttributeSet            parent, 
  194.     TQ3AttributeSet            child, 
  195.     TQ3AttributeSet            result);
  196.  
  197.  
  198. /******************************************************************************
  199.  **                                                                             **
  200.  **                            Custom Element Registration                         **
  201.  **                                                                             **
  202.  *****************************************************************************/
  203.  
  204. /*
  205.  * Element Methods - 
  206.  *
  207.  *         When you create a custom element, you control what structures are 
  208.  *        passed around the API. For example, you may allow the Q3Set_Add call 
  209.  *        take one type of argument, store your element internally in some 
  210.  *        abstract data type, and have the Q3Set_Get call take a different 
  211.  *        argument.
  212.  *
  213.  *        For example:
  214.  *            
  215.  *        There are four calls which at some point will copy an element:
  216.  *
  217.  *        Q3Set_Add (copied from Application memory to QuickDraw3D memory)
  218.  *        Q3Set_Get (copied from QuickDraw3D memory to Application memory)
  219.  *        Q3Object_Duplicate (all elements are copied internally)
  220.  *        Q3AttributeSet_Inherit (all elements are copied internally)
  221.  *
  222.  *         Either CopyAdd or CopyReplace is called during the "_Add" call.
  223.  *            - CopyAdd is destructive and should assume "toElement" is garbage
  224.  *            - CopyReplace is replacing an existing element.
  225.  *
  226.  *         CopyGet is called during the "_Get" call.
  227.  *
  228.  *         CopyDuplicate is called to duplicate an element's internal structure.
  229.  *
  230.  * Attributes Methods - 
  231.  *
  232.  *        For copying data while Inheriting. Element methods are used
  233.  *        at all other times.
  234.  *    
  235.  *         CopyInherit is called to duplicate an element's internal structure 
  236.  *            during inheritance. You should make this as fast as possible.
  237.  *            (for example, if your custom element contains objects, you
  238.  *             should do a Q3Shared_GetReference instead of a Q3Object_Duplicate)
  239.  *            
  240.  *        The ElementDelete method will be called for all of your elements copied 
  241.  *        around via CopyAdd, CopyReplace, CopyDuplicate, and CopyInherit.
  242.  *        If CopyGet allocates any memory in it's destination, it is up to the app 
  243.  *        to delete it on its side.
  244.  */
  245.  
  246. #define kQ3MethodTypeElementCopyAdd            Q3_METHOD_TYPE('e','c','p','a')
  247. #define kQ3MethodTypeElementCopyReplace        Q3_METHOD_TYPE('e','c','p','r')
  248. #define kQ3MethodTypeElementCopyGet            Q3_METHOD_TYPE('e','c','p','g')
  249. #define kQ3MethodTypeElementCopyDuplicate    Q3_METHOD_TYPE('e','c','p','d')
  250. #define kQ3MethodTypeElementDelete            Q3_METHOD_TYPE('e','d','e','l')
  251.  
  252. typedef TQ3Status (*TQ3ElementCopyAddMethod)(    
  253.     const void            *fromAPIElement,            /* element from _Add API call */
  254.     void                *toInternalElement);        /* to new QD3D internal element */
  255.  
  256. typedef TQ3Status (*TQ3ElementCopyReplaceMethod)(
  257.     const void            *fromAPIElement,            /* element from _Add API call */
  258.     void                *ontoInternalElement);        /* replacing QD3D internal element */
  259.  
  260. typedef TQ3Status (*TQ3ElementCopyGetMethod)(
  261.     const void            *fromInternalElement,        /* from QD3D internal element */
  262.     void                *toAPIElement);                /* to _Get API call */
  263.  
  264. typedef TQ3Status (*TQ3ElementCopyDuplicateMethod)(
  265.     const void            *fromInternalElement,        /* from QD3D internal element */
  266.     void                *toInternalElement);        /* to new QD3D internal element */
  267.  
  268. typedef TQ3Status (*TQ3ElementDeleteMethod)(    
  269.     void                *internalElement);
  270.  
  271. QD3D_EXPORT TQ3ObjectClass Q3ElementClass_Register(
  272.      TQ3ElementType        elementType,
  273.     const char            *name,
  274.     unsigned long        sizeOfElement,
  275.     TQ3MetaHandler        metaHandler);
  276.  
  277. QD3D_EXPORT TQ3Status Q3ElementType_GetElementSize(
  278.      TQ3ElementType        elementType,
  279.     unsigned long        *sizeOfElement);
  280.  
  281.  
  282. /******************************************************************************
  283.  **                                                                             **
  284.  **                        Custom Attribute Registration                         **
  285.  **                                                                             **
  286.  *****************************************************************************/
  287.  
  288. #define kQ3MethodTypeAttributeInherit        Q3_METHOD_TYPE('i','n','h','t')
  289. #define kQ3MethodTypeAttributeCopyInherit    Q3_METHOD_TYPE('a','c','p','i')
  290.  
  291. typedef TQ3Boolean TQ3AttributeInheritMethod;    
  292. /* return kQ3True or kQ3False in your metahandler */
  293.  
  294. typedef TQ3Status (*TQ3AttributeCopyInheritMethod)(
  295.     const void            *fromInternalAttribute,        /* from QD3D internal element */
  296.     void                *toInternalAttribute);        /* to new QD3D internal element */
  297.  
  298. QD3D_EXPORT TQ3ObjectClass Q3AttributeClass_Register(
  299.     TQ3AttributeType    attributeType,
  300.     const char            *creatorName,
  301.     unsigned long        sizeOfElement,
  302.     TQ3MetaHandler        metaHandler);
  303.  
  304. #ifdef __cplusplus
  305. }
  306. #endif    /* __cplusplus */
  307.  
  308. #endif /*  QD3DSet_h */
  309.